package Animal;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:恋恋
 * Date:2022-09-08
 * Time:19:13
 */
public class Animal {
    String name;
    int age;
    //private修饰的成员继承了子类，只是子类不能访问，若想访问只能间接不能直接---->setting and getting
    private int sex;
    protected int see;
    static int height;
    public void eat(){
        height=162;
        System.out.println(name+"正在吃饭！");
    }
    public void sleep(){
        System.out.println(name+"正在睡觉！");
    }
    public static void fun0(){

    }
    public void methodA(){
        System.out.println("父类中的methodA()");
    }
    public void methodB(){
        System.out.println("夫类中的methodB()");
    }

//    public Animal(String name, int age) {
//        this.name = name;
//        this.age = age;
//        System.out.println("父类的构造方法");
//    }

   //父类的实例代码块
   {
       System.out.println("父类的实例代码块");
   }
   //父类的静态代码块
    static{
       System.out.println("父类的静态代码块");
   }
   //父类的构造方法
    public Animal() {
        System.out.println("父类的构造方法");
    }
    public static void main(String[] args) {
        Dog dog1=new Dog();
        System.out.println("-----------------------------");
        Dog dog2=new Dog();
    }
}
class Dog extends Animal{
    //子类的实例化代码块
    {
        System.out.println("子类的实例代码块");
    }
    //子类的静态代码块
    static {
        System.out.println("子类的静态代码块");
    }
   //子类的构造方法
    public Dog() {
        System.out.println("这是子类的构造方法");
    }
}
//    public int silly;
//  this(20);
//    public Dog(int silly) {
//        this.silly = silly;
//    }
////子类构造方法中，只要在编译器界面上不会同时出现this和super。就不会报错